## CMake 最低版本号要求
cmake_minimum_required (VERSION 2.8.12)

## 项目信息
project (mytest)

set(INC_DIR ${PROJECT_SOURCE_DIR}/include)
include_directories(${INC_DIR})

if (CMAKE_SYSTEM_NAME MATCHES "Linux")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char)")  ## arm平台设置，将char类型设置有符号的char类型
	#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lpthread")
	if ("${debug}" STREQUAL "1")
		add_definitions(-DDEBUG)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lpthread")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -ggdb -Wall -fgnu89-inline -Wno-misleading-indentation")
		message("库的编译类型为debug")
	elseif ("${release}" STREQUAL "1")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -fno-strict-aliasing")
		message("库的编译类型为release")
	elseif ("${error-check}" STREQUAL "1")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -fsanitize=address -fstack-protector-all")
		message("库的编译类型为error-check")
	else()
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -ggdb -Wall -fgnu89-inline -Wno-misleading-indentation")
		message("库的编译类型为默认")
	endif()

	if ("${CMAKE_SYSTEM_NAME}" STREQUAL "aarch64")
		set(LIBS ${PROJECT_SOURCE_DIR}/libs_linux_arm)
	else()
		set(LIBS ${PROJECT_SOURCE_DIR}/libs_linux)
	endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
	set(LIBS ${PROJECT_SOURCE_DIR}/libs_windows)
endif ()
	
## 设置ctest选项
option (ENABLE_CJSON_TEST "Enable building unity test" ON)
if (ENABLE_CJSON_TEST)
	enable_testing()
endif()

add_subdirectory(${PROJECT_SOURCE_DIR}/src)
#add_subdirectory(${PROJECT_SOURCE_DIR}/demo_lib)

#if (NOT TARGET uninstall)
#configure_file(
#"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
#"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake"
#IMMEDIATE @ONLY)

#add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake)
#endif()

